const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    mode: 'production',
    entry: './src/main.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js',
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './public/index.html'
        })
    ],
    module: {
        rules: [
            {
                test: /\.css$/i,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.less$/i,
                use: ["style-loader", "css-loader", "less-loader"],
            },
            {
                test: /\.(png|jpe?g|svg|gif)/i,
                type: 'asset',
                generator: {
                    filename: 'image/[hash:20][ext]'
                }
            },
            {
                test: /\.(eot|svg|ttf|woff2?)$/i,
                type:'asset/resource',
                generator:{
                  filename:'font/[name].[hash:6][ext]'
                }
              },
              {
                test: /\.js$/i,
                exclude: /node_modules/,
                use: {
                  loader: 'babel-loader',
                  options: {
                    presets: ['@babel/preset-env']
                  }
                }
              }
        ],
    }
}